﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Audit_Configuration_Oracle.Views
{
    public partial class MDIContainer : Form
    {
        private int childFormNumber = 0;
        ACO_Audit_Rules rules = null;
        ACO_New_Rule rule = null;
        ACO_Audit_History history = null;
        About box = null;

        public bool IsLogged { get; set; }

        public MDIContainer()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }

        private void ShowNewRule(object sender, EventArgs e)
        {
            if (rule == null)
            {
                rule = new ACO_New_Rule();
                rule.MdiParent = this;
            }            
            rule.Show();
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void MDIContainer_Load(object sender, EventArgs e)
        {
            Form login = new ACO_LogIn();
            login.ShowDialog();
        }

        private void logoutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form child in MdiChildren)
            {
                child.Hide();
            }

            Form login = new ACO_LogIn();
            IsLogged = false;
            login.ShowDialog();
        }

        private void historialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (history == null)
            {
                history = new ACO_Audit_History();
                history.MdiParent = this;
            }

            history.Show();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (box == null)
            {
                box = new About();
                box.MdiParent = this;
            }
            box.Show();
        }

        private void toolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (rules == null)
            {
                rules = new ACO_Audit_Rules();
                rules.MdiParent = this;
            }
            rules.Show();
        }
    }
}
